import request from './request'

// 获取曲风树
export const getGenreTree = () => {
  return request.get('/genre/tree')
}

// 添加曲风
export const addGenre = (genreData) => {
  return request.post('/genre', genreData)
}

// 修改曲风
export const updateGenre = (id, genreData) => {
  return request.put(`/genre/${id}`, genreData)
}

// 获取一级曲风
export const getMainGenres = () => {
  return request.get('/genre/main', {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 根据一级曲风获取二级曲风
export const getSubGenres = (parentId) => {
  return request.get('/genre/sub', {
    params: { parentId: parentId },
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 根据二级曲风获取三级曲风
export const getSubTypeGenres = (parentId) => {
  return request.get('/genre/subtype', {
    params: { parentId: parentId },
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 根据音乐id查询对应的三级曲风
export const getGenreByMusicId = (musicId) => {
  return request.get(`/genre/genres/${musicId}`)
}

// 根据ID获取曲风详情
export const getGenreById = (genreId) => {
  return request.get(`/genre/${genreId}`)
}
